package com.example.player.presentation.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.ListFragment;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.player.R;
import com.example.player.domain.entity.PlayList;
import com.example.player.presentation.adaptor.ListItemAdapter;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.rxjava3.disposables.CompositeDisposable;

/**
 * 歌单，对应playlists.xml
 * @author 朱文权
 * */
public class PlaylistsFragment extends Fragment {
    //统一管理订阅
    private CompositeDisposable disposables = new CompositeDisposable();
    //歌单条目展示器
    private ListItemAdapter adapter;
    //展示项
    private RecyclerView recyclerView;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.playlists,container);
        recyclerView=view.findViewById(R.id.list_item);
        recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));
        List<PlayList> lists=new ArrayList<>();
        PlayList playList=new PlayList();
        playList.setCount(2);
        playList.setTitle("我的歌单");
        playList.setCoverPath("/storage/emulated/0/Pictures/アイドル (偶像)封面.png");
        lists.add(playList);
        adapter=new ListItemAdapter(lists);
        recyclerView.setAdapter(adapter);
        return view;
    }
}
